Skip to content

Qs issue#77

Open
dana89co wants to merge 3 commits intoPRODfrom
qs_issue
Open

Qs issue#77
dana89co wants to merge 3 commits intoPRODfrom
qs_issue

Conversation

@dana89co
Copy link
Copy Markdown
Contributor

@dana89co dana89co commented Mar 30, 2026

Hi @RossanaTat,

Here is the PR to fix the issue of load_pip_data and it also fixes some stuff with the examples that were affecting the check. Let me know what you think, especially for the "aux" functions. Thank you for reviewing!

Summary by CodeRabbit

  • New Features

    • New data validation function now available in public API for checking data identifiers
  • Updates

    • Migrated from qs to qs2 data storage format for improved file handling and performance
    • Updated package dependencies to support qs2 library
  • Documentation

    • Enhanced documentation examples with clearer execution controls and updated usage patterns

@dana89co dana89co requested a review from RossanaTat March 30, 2026 21:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The pipload package is migrated from the qs to qs2 serialization format across multiple files. The check_dlw_id_name function is exported to the public API. Package dependencies are updated to remove qs and pins while adding qs2. Documentation examples are wrapped in \dontrun{} blocks to prevent automatic execution.

Changes

Cohort / File(s) Summary
Dependency and API Changes
DESCRIPTION, NAMESPACE
Updated package imports to remove qs and pins, add qs2; exported check_dlw_id_name to public API.
Format Migration and Documentation
R/OLD_pip_load_aux.R, R/load_pip_data.R, R/pip_load_all_aux.R
Replaced "qs" format handling with "qs2" throughout; updated file path construction and read operations; wrapped roxygen examples in \dontrun{} blocks.
Export and Documentation Updates
R/load_dlw_data.R, R/pip_merge_aux.R
Changed check_dlw_id_name roxygen directive from @keywords internal to @export; added \dontrun{} blocks to example sections in multiple functions.
Generated Documentation Files
man/aux_ids.Rd, man/load_dlw_data.Rd, man/load_pip_data.Rd, man/pip_load_aux.Rd, man/pip_merge_aux.Rd
Updated .Rd documentation examples to reflect .qs2 format, changed example parameters (country codes, id names), and wrapped example calls in \dontrun{} blocks.
Vignette Updates
vignettes/read_write_pins.Rmd
Updated examples to use .qs2 extension instead of .qs, adjusted function call formatting and pipe operator usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From qs to qs2 we hop with glee,
Format migration, swift and free!
Public APIs expand their call,
While \dontrun{} protects them all,
A tidier warren for us all! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Qs issue' is vague and generic, using non-descriptive terminology that fails to convey the actual scope and nature of the changeset. Consider a more descriptive title that captures the main change, such as 'Replace qs with qs2 dependency and update examples' or 'Migrate from qs to qs2 package throughout codebase'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch qs_issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
R/OLD_pip_load_aux.R (1)

362-385: ⚠️ Potential issue | 🟠 Major

find_path() can throw index errors before the intended not-found abort.

At Line 368, ext_order[[i]] is accessed in an unbounded while loop. If no extension matches, i exceeds length(ext_order) and errors before Line 379’s cli_abort.

🔧 Proposed fix
 find_path <- function(file_paths) {
 
   extensions <- fs::path_ext(file_paths)
   ext_order <- c("qs2", "fst", "rds", "dta")
 
-  f <- FALSE
-  i <- 1
-  while (f == FALSE) {
-
-    ext <- ext_order[[i]]
-
-    if(ext  %in% extensions) {
-      p <- which(extensions == ext)
-      f <- file_paths[[p]]
-    } else {
-      i <- i + 1
-    }
-
-  }
-
-  if (f == FALSE) {
-    msg     <- c(
-      "File not found",
-      "*" = "At least one of the following extension should be available: {.file {ext_order}}"
-    )
-    cli::cli_abort(msg,
-                   class = "error_class")
-  }
-
-  return(f)
+  for (ext in ext_order) {
+    if (ext %in% extensions) {
+      p <- which(extensions == ext)[1]
+      return(file_paths[[p]])
+    }
+  }
+
+  msg <- c(
+    "File not found",
+    "*" = "At least one of the following extensions should be available: {.file {ext_order}}"
+  )
+  cli::cli_abort(msg, class = "error_class")
 
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@R/OLD_pip_load_aux.R` around lines 362 - 385, The while loop using
ext_order[[i]] can run past the end and throw an index error before the intended
cli_abort; fix by bounding the loop (e.g., replace the unbounded while with a
for loop over ext_order or change the while condition to while(!f && i <=
length(ext_order))) so you never call ext_order[[i]] out-of-range, using the
existing variables ext_order, extensions, file_paths, f and i and keeping the
post-loop cli::cli_abort when no match is found.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@R/OLD_pip_load_aux.R`:
- Around line 334-343: The read_by_format branch leaves x NULL when pformat is
unrecognized; update read_by_format (the branch that sets x based on pformat) to
explicitly error when pformat is not one of the supported values ("qs2", "fst",
"rds", "dta") by calling abort/stop with a clear message that includes the
invalid pformat and the allowed formats so the function fails fast instead of
returning NULL.

---

Outside diff comments:
In `@R/OLD_pip_load_aux.R`:
- Around line 362-385: The while loop using ext_order[[i]] can run past the end
and throw an index error before the intended cli_abort; fix by bounding the loop
(e.g., replace the unbounded while with a for loop over ext_order or change the
while condition to while(!f && i <= length(ext_order))) so you never call
ext_order[[i]] out-of-range, using the existing variables ext_order, extensions,
file_paths, f and i and keeping the post-loop cli::cli_abort when no match is
found.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 471de3d8-8869-4b0c-ad8c-f909fa58f889

📥 Commits

Reviewing files that changed from the base of the PR and between 21c4496 and 2e648d2.

📒 Files selected for processing (13)
  • DESCRIPTION
  • NAMESPACE
  • R/OLD_pip_load_aux.R
  • R/load_dlw_data.R
  • R/load_pip_data.R
  • R/pip_load_all_aux.R
  • R/pip_merge_aux.R
  • man/aux_ids.Rd
  • man/load_dlw_data.Rd
  • man/load_pip_data.Rd
  • man/pip_load_aux.Rd
  • man/pip_merge_aux.Rd
  • vignettes/read_write_pins.Rmd

Comment on lines 334 to 343
x <-
if (pformat == "qs") {

qs::qread(file_to_load)

} else if (pformat == "fst") {

if (pformat == "qs2") {
qs2::qs_read(file_to_load)
} else if (pformat == "fst") {
fst::read_fst(file_to_load, as.data.table = TRUE)

} else if (pformat == "rds") {

readr::read_rds(file_to_load)

} else if (pformat == "dta") {

haven::read_dta(file_to_load)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Unsupported extensions are not rejected explicitly in read_by_format().

If pformat is unknown, x is left NULL and returned silently, which can fail later in less obvious ways. Fail fast with a clear abort at the read boundary.

🔧 Proposed fix
 read_by_format <- function(file_to_load) {
 
   pformat <- fs::path_ext(file_to_load)
 
   x <-
     if (pformat == "qs2") {
       qs2::qs_read(file_to_load)
     } else if (pformat == "fst") {
       fst::read_fst(file_to_load, as.data.table = TRUE)
     } else if (pformat == "rds") {
       readr::read_rds(file_to_load)
     } else if (pformat == "dta") {
       haven::read_dta(file_to_load)
+    } else {
+      cli::cli_abort(c(
+        "Unsupported file format",
+        x = "Extension {.field {pformat}} is not supported.",
+        i = "Supported formats: {.field {c('qs2', 'fst', 'rds', 'dta')}}"
+      ), class = "pipload_error")
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@R/OLD_pip_load_aux.R` around lines 334 - 343, The read_by_format branch
leaves x NULL when pformat is unrecognized; update read_by_format (the branch
that sets x based on pformat) to explicitly error when pformat is not one of the
supported values ("qs2", "fst", "rds", "dta") by calling abort/stop with a clear
message that includes the invalid pformat and the allowed formats so the
function fails fast instead of returning NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant